package br.com.ravi.testes;

import java.security.NoSuchAlgorithmException;
import java.util.List;

import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

import br.com.ravi.utils.HibernateUtil;

public class TesteHibernate {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws NoSuchAlgorithmException {
		SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
		Session session = sessionFactory.getCurrentSession();
		session.beginTransaction();
		SQLQuery query = session.createSQLQuery("SELECT * FROM CADUSUARIO");
		List<Object> list = query.list();
		
		for (Object object : list) {
			Object[] objArray = (Object[]) object;
			for (Object object2 : objArray) {
				System.out.println(object2);
			}
		}
		session.getTransaction().commit();
		
		sessionFactory.close();
	}
}